package com.weiiew.recipeservice.annotation;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Caching;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @Description
 * @Author 魏锴
 * @Date 2025/4/8
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Caching(evict = {
        @CacheEvict(cacheNames = "recipe:list", key = "#version + '&*'", cacheManager = "fuzzyCacheManager"),
        @CacheEvict(cacheNames = "recipe:length", key = "#version + '&*'", cacheManager = "fuzzyCacheManager"),
        @CacheEvict(cacheNames = "recipe:list:item:sort:product", key = "#version"),
        @CacheEvict(cacheNames = "recipe:list:item:sort:ingredient", key = "#version"),
        @CacheEvict(cacheNames = "recipe:list:build:sort:product", key = "#version"),
        @CacheEvict(cacheNames = "recipe:list:by:build", allEntries = true),
        @CacheEvict(cacheNames = "recipe:list:by:ingredient", allEntries = true),
        @CacheEvict(cacheNames = "recipe:list:by:product", allEntries = true),
        @CacheEvict(cacheNames = "recipe:list:cal:item", key = "#version + '&*'", cacheManager = "fuzzyCacheManager"),
        @CacheEvict(cacheNames = "cal:recipe", allEntries = true),
        @CacheEvict(cacheNames = "tran:recipe", allEntries = true),
        @CacheEvict(cacheNames = "recipe:vo", key = "#id", condition = "id != null"),
})
public @interface RecipeChangeCacheEvict {
}
